<template>
  <view class="custom-header" :style="{ paddingTop: statusBarHeight + 'px' }">
    <view class="header-content">
      <view class="header-left" @click="handleSearch">
        <image class="search-icon" src="https://jyoungy.oss-cn-beijing.aliyuncs.com/jyy-mini-sale/icons/search.png" mode="aspectFit"></image>
      </view>
      <view class="header-center">
        <image class="logo" src="https://jyoungy.oss-cn-beijing.aliyuncs.com/jyy-mini-sale/logo.png" mode="heightFix"></image>
      </view>
      <view class="header-right">
        <!-- 右侧预留空间，保持对称 -->
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'CustomHeader',
  data() {
    return {
      statusBarHeight: 0
    }
  },
  mounted() {
    this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
    this.$nextTick(() => {
      // 计算总高度：状态栏高度 + 内容区域高度(88rpx)
      const totalHeight = this.statusBarHeight + uni.upx2px(88);
      this.$emit('height-change', totalHeight);
    });
  },
  methods: {
    handleSearch() {
      uni.navigateTo({
        url: '/pages/search/index'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.custom-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: #ffffff;
  z-index: 999;

  .header-content {
    height: 88rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30rpx;
  }

  .header-left {
    width: 60rpx;
    height: 60rpx;
    display: flex;
    align-items: center;
    justify-content: center;

    .search-icon {
      width: 40rpx;
      height: 40rpx;
    }
  }

  .header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;

    .logo {
      height: 50rpx;
    }
  }

  .header-right {
    width: 60rpx;
  }
}
</style> 